<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
      https://leetcode-cn.com/problems/zi-fu-chuan-de-pai-lie-lcof/
      思路：https://leetcode-cn.com/problems/zi-fu-chuan-de-pai-lie-lcof/solution/javascript-hui-su-fa-by-menteceso/
     */
    function permutation(s) {
      let res = new Set()
      let visited = {}
      dfs('')
      return [...res]

      function dfs(path) {
        if (path.length === s.length) {
          res.add(path)
          return 
        }

        for (let i = 0; i < s.length; i++) {
          if (visited[i]) continue
          visited[i] = true
          dfs(path + s[i])
          visited[i] = false
        }
      }
    }
  </script>
</body>
</html>